package com.sikaryofficial.backend.controller.information;

import com.sikaryofficial.backend.annotation.TenantFilter;
import com.sikaryofficial.backend.domain.dto.req.information.ArticleTagReq;
import com.sikaryofficial.backend.domain.dto.resp.information.ArticleTagDTO;
import com.sikaryofficial.backend.manager.information.ArticleTagManager;
import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.common.core.web.controller.BaseController;
import com.sikaryofficial.common.log.annotation.Log;
import com.sikaryofficial.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文章标签Controller
 *
 * @author qinjinyuan
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/article/tag")
@Api(tags = "资讯-文章标签")
public class ArticleTagController extends BaseController {
    @Autowired
    private ArticleTagManager articleTagManager;

    /**
     * 新增文章标签
     */
    @Log(title = "文章标签", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    @ApiOperation("文章标签保存")
    @TenantFilter
    public R<Void> save(@Validated @RequestBody ArticleTagReq articleTag) {
        articleTagManager.saveOrUpdate(articleTag);
        return R.ok();
    }

    /**
     * 文章当前选择标签数据
     */
    @GetMapping("/current")
    @ApiOperation("文章当前选择标签数据")
    public R<ArticleTagDTO> currentTag() {
        return R.ok(articleTagManager.currentTag());
    }
}
